<!--@thymesVar id="user" type="ru.tbcarus.spendingsb.model.User"-->
<!--@thymesVar id="role" type="ru.tbcarus.spendingsb.model.Role"-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
<!--    <meta name="viewport" content="width=device-width, initial-scale=1">-->
    <title>Пользователи</title>
    <div th:replace="~{fragments/headTag :: headTag}"></div>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm"
        crossorigin="anonymous"></script>
<nav th:replace="~{fragments/loginBodyHeader :: loginBodyHeader}"></nav>
<div class="jumbotron pt-3 pb-3 bg-light">
    <div class="container">
        <div th:if="${param.error}" class="alert alert-danger">
            Invalid some fields.
        </div>
        <div class="d-flex justify-content-center">
            <!--/*@thymesVar id="user" type="ru.tbcarus.spendingsb.model.User"*/-->
            <form method="post" th:action="@{/register}" th:object="${user}" class="form"
                  id="userForm" style="width: 300px">
                <div class="form-group mb-4">
                    <label for="name">Имя:</label>
                    <input type="text" class="form-control" id="name" th:field="*{name}" th:value="*{name}">
                    <p class="alert alert-danger" th:if="${#fields.hasErrors('name')}" th:errors="*{name}"></p>
                </div>

                <div class="form-group mb-4">
                    <label for="email">E-mail:</label>
                    <input type="text" class="form-control" id="email" th:field="*{email}" th:value="*{email}">
                    <p class="alert alert-danger" th:if="${#fields.hasErrors('email')}" th:errors="*{email}"></p>
                    <div th:if="${#fields.hasErrors('global')}">
                        <p class="alert alert-danger" th:each="err : ${#fields.errors('global')}" th:text="${err}"></p>
                    </div>
                </div>

                <div class="form-group mb-4">
                    <label for="password">Пароль:</label>
                    <input type="password" class="form-control" id="password" th:field="*{password}"
                           th:value="*{password}">
                    <p class="alert alert-danger" th:if="${#fields.hasErrors('password')}" th:errors="*{password}"></p>
                </div>

                <div class="form-group mb-4">
                    <label for="start_day">Начальный день месяца:</label>
                    <select id="start_day" class="form-control" name="startDay">
                        <option th:value="${user.startPeriodDate.dayOfMonth}"
                                th:text="${user.startPeriodDate.dayOfMonth}" selected hidden>TEXT
                        </option>
                        <option th:each="i : ${#numbers.sequence(1, 28, 1)}" th:value="${i}"
                                th:text="${i}"></option>
                    </select>
                </div>

                <div class="d-flex align-items-center justify-content-center">
                    <button type="submit" class="btn btn-top m-1">Зарегистрироваться</button>
                    <input type="button" value=" Отменить " class="btn btn-bottom m-1"
                           th:onclick="|window.location.href='@{/admin/users}'|">
                </div>
            </form>
        </div>
    </div>
</div>

<!--    copyright-->
<div th:replace="~{fragments/footer :: copy}"></div>
</body>
</html>